package com.example.springbootcondition.config;

import com.example.springbootcondition.condition.ConditionOnClass;
import com.example.springbootcondition.domain.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: springboot1
 * @description:
 * @author: zhanghz001
 * @create: 2020-12-08 15:54
 **/
@Configuration
public class UserConfig {

    @Bean
    // @Conditional({com.example.springbootcondition.condition.ClassCondition.class})
    @ConditionOnClass({"redis.clients.jedis.Jedis", "com.alibaba.fastjson.JSON"})
    public User user() {
        return new User();
    }

    @Bean
    // @Conditional({com.example.springbootcondition.condition.ClassCondition.class})
    @ConditionalOnProperty(name = "name", havingValue = "itheima")
    public User user2() {
        return new User();
    }
}
